import os
import tempfile
import shutil
import cv2

def main( directory ):
    file_list = os.listdir( directory )
    base_dir = os.path.abspath( directory )

    for f in file_list:
        img_name = tempfile.mktemp( suffix = ".jpg" , dir = base_dir )
        ff = os.path.join( base_dir , f )
        shutil.copy( ff , img_name )
        os.remove( ff )

def cvtImg( directory ):
    file_list = os.listdir( directory )
    base_dir = os.path.abspath( directory )

    file_list = [ x for x in file_list if x[-4:] == ".jpg" ]

    for f in file_list:
        ff = os.path.join( base_dir , f )
        img = cv2.imread( ff )
        if ( img.shape[2] != 3 ):
            print( f )
            print( img.shape[2] )

if __name__ =="__main__":
    #main( "./cellphone" )
    cvtImg( "/home/jh/working_data/idData_fullIMG/dataset/neg" )
